Skip to content

[d3d11,util] Work around SRV use-after-free in Black Ops 4 - #6051

Open
reqlay wants to merge 1 commit into
doitsujin:masterfrom
reqlay:bo4-fix
Open

reqlay wants to merge 1 commit into
doitsujin:masterfrom
reqlay:bo4-fix

Conversation

@reqlay

@reqlay reqlay commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Black Ops 4 keeps binding SRVs after it has released them, and crashes when exiting a match to the lobby.

This is mostly harmless while the freed memory is still intact, since the view is already marked dead and its internal pointers are nulled, so a stale bind just ends up binding nothing. It breaks once that memory gets reused for something else. In the case I traced it was reused for a DxvkBuffer, and when the game called *GetShaderResources, the AddRef on the stale binding went through the buffer's vtable and hit its deleting destructor instead. The buffer gets destroyed while it's still in use and the heap falls over shortly after.

This adds a d3d11.srvQuarantine option that keeps the last 4096 destroyed SRVs allocated before actually freeing them, so stale binds keep hitting a dead view instead of whatever ends up in that memory. If a view is still bound when it leaves the ring, it is leaked rather than freed, so the eventual private release from the context does not write into freed memory. The option is off by default and only enabled for BlackOps4.exe.

This is the same class of bug as the Sims 4 SRV issue (427e706), but nulling the members is not enough here since the memory itself gets recycled.

Tested on Proton with multiple match exits in a row. The crash was 100% reproducible before and has not happened since.

Proton issue: ValveSoftware/Proton#10230

Black Ops 4 keeps binding SRVs after releasing them. This is harmless
while the memory is intact, because the dead refcount marker stops the
view from being freed twice. Once the allocation is reused for another
object, the AddRef in *GetShaderResources calls into that object's
vtable and the game crashes on match exit.

Add a d3d11.srvQuarantine option that keeps the last 4096 destroyed
SRVs allocated before freeing them, and enable it for BlackOps4.exe.
Views that are still bound when they leave the ring are leaked instead
of freed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant